<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>loginoooo</title>
</head>
<body>
<!--<form method="post" action="" id="form1">-->
    <div class="col-md-12">
        <div class="form-group">
            <label class="col-sm-3 control-label">用户名：</label>
                <input name="username" type="text" class="form-control" placeholder="请输入用户名">
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">密码框：</label>
                <input type="password" class="form-control" name="password" placeholder="请输入密码">
        </div>
        <div><input type="submit" value="提交" id="submit1"></div>
    </div>
<!--</form>-->
</body>
<script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
<script>
    $("#submit1").click(function () {
        // $(document).on("click","submit1",function () {
        var fields = $('#form1').serializeArray();
        var obj = {}; //声明一个对象
        $.each(fields, function(index, field) {
            obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
        })
        console.log("dhuhuihwduqi");
        // $.ajax({
        //     type: "post",
        //     url: "http://localhost:8080/user/login",
        //     async: true,
        //     contentType: 'application/json',
        //     //dataType: 'JSON',
        //     data: JSON.stringify(obj),//将对象转为json字符串
        //     success: function(obj) {
        //
        //     }
        // });
        $.post("http://localhost:8080/user/login",
            JSON.stringify(obj),
             'application/json',
            function(obj) {
            console.log("dhuhuihwduqi");
        }
    );
    })
    // var fields = $('#form1').serializeArray();
    // var obj = {}; //声明一个对象
    // $.each(fields, function(index, field) {
    //     obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
    // })
    // $.ajax({
    //     type: "post",
    //     url: "http://localhost:8080/user/login",
    //     async: true,
    //     contentType: 'application/json',
    //     dataType: 'JSON',
    //     data: JSON.stringify(obj),//将对象转为json字符串
    //     success: function(obj) {
    //
    //     }
    // });
</script>
</html>